Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to mitigate locked machine.config #1825

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

tyrielv
Copy link
Contributor

@tyrielv tyrielv commented Nov 14, 2024

Antivirus occasionally opens machine.config for writing. If a .NET Framework app happens to launch during that brief window, it will create a popup with an error message and not continue until popup is closed. Since GVFS periodically runs maintenance tasks, it is not uncommon for users to find the error popup waiting for them first thing in the morning.
In addition, any GVFS C# app that makes HTTP requests will initialize ServicePointManager. This call can also fail if machine.config is locked (ie if the lock started after the app started so it didn't do the pop-up, or if the pop-up has been closed/skipped and the machine.config is still locked), and once it does it is unrecoverable.

This pull request attempts to mitigate the effects of machine.config locking in two ways:

  1. GitHooksLoader is responsible for starting GVFS.Hooks.exe, by far the most likely place to hit this issue. By calling SetErrorMode(SEM_FAILCRITICALERRORS) before invoking GVFS.Hooks.exe, the popup is suppressed.
  2. In HttpRequestor initialization, try briefly to lock machine.config ourselves for reading before initializing ServicePointManager.

Copy link
Contributor

@derrickstolee derrickstolee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clear motivation, @tyrielv! The code changes look solid. Too bad that it's probably not worth trying to create a test for this scenario.

@mjcheetham mjcheetham merged commit e33cc07 into microsoft:master Dec 12, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants